<template>
  <section class="oa-form__table">
    <h5>{{ approve.name }}</h5>
    <table cellpadding="0" cellspacing="0">
      <tr v-if="$route.query.from != 'new'">
        <td>事务编号</td>
        <td>
          {{ approve.name }}
          <span v-if="approve && approve.code">{{ approve.code }}</span>
        </td>
      </tr>
      <tr>
        <td>流程名称</td>
        <td>
          <span v-if="$route.query.from == 'new'">新建{{ approve.name }}</span>
          <span v-else>
            {{ approve.approve_name }}
          </span>
        </td>
      </tr>
      <tr>
        <td>申请事由</td>
        <td :title="reason"><el-input placeholder="申请事由" type="textarea" v-model="reason" :disabled="$route.query.from != 'new'"/></td>
      </tr>
    </table>
    <h3 class="oa-form__table-title">
      <span v-if="$route.query.from === 'new'">{{ approve.name }}</span>
      <span v-else>
        {{ approve.approve_name }}
      </span>
    </h3>
    <table class="achievement__tab">
      <tr class="border_0">
        <td>考核周期:</td>
        <td>
          <el-date-picker
            value-format="yyyy-MM-dd"
            type="date"
            v-model="applyTime"
            :disabled="$route.query.from !== 'new'"
            placeholder="考核周期">
          </el-date-picker>
        </td>
        <td>部门:</td>
        <td width="400">
          <el-select v-model="department" :disabled="$route.query.from != 'new'" placeholder="请选择">
            <el-option
              v-for="item in departments"
              :key="item.value"
              :label="item.label"
              :value="item.value">
            </el-option>
          </el-select>
        </td>
        <td>姓名:</td>
        <td>
          <el-select v-model="value" style="width:60%" :disabled="$route.query.from != 'new'" placeholder="请选择"  @change="selectStaff($event)">
            <el-option
              v-for="item in staff"
              :key="item.value"
              :label="item.label"
              :value="item">
            </el-option>
          </el-select>
        </td>
        <td>岗位:<span style="display:inline-block;width:100px;padding-left:10px;"><el-input v-model="gangwei" :disabled="$route.query.from !== 'new'" placeholder="岗位"/></span></td>
      </tr>
      <tr>
        <td class="_name">考核指标</td>
        <td class="_name">指标定义</td>
        <td class="_name">权重</td>
        <td class="_name">评分说明</td>
        <td class="_name">数据来源</td>
        <td class="_name">自评</td>
        <td class="_name">评估得分</td>
        <!-- <td class="_name">扣分事项说明</td> -->
      </tr>
      <tr>
        <td rowspan="3">设计</td>
        <td>项目对接</td>
        <td>15%</td>
        <td>
          在客服部门提供完整素材后，安排本部门24小时内完成设计初稿（1、超过24小时扣2分，超过48小时扣4分；2、首次被选定无修改（加分条件：累需3次以上（含3次），每次加2分只限老客户新设计版面以及新客户新版面，不计算老客户版面微小改动））
        </td>
        <td rowspan="3">客服部</td>
        <td><el-input v-model="obj.a98" :disabled="obj.a98Flag" /></td>
        <td><el-input v-model="obj.a107" :disabled="obj.a107Flag" /></td>
      </tr>
      <tr>
        <td>工作表格、档案</td>
        <td>10%</td>
        <td>
          工作表制作完整、及时、提供信息使用，以第二次修改定稿为准。设计档案规范化管理（未达成扣2分）
        </td>
        <td><el-input v-model="obj.a99" :disabled="obj.a99Flag" /></td>
        <td><el-input v-model="obj.a108" :disabled="obj.a108Flag" /></td>
      </tr>
      <tr>
        <td>设计定稿</td>
        <td>15%</td>
        <td>保证设计作品美观、满足需求并与品牌调性匹配，需3个工作日内完成定稿(未达成扣2分)</td>
        <td><el-input v-model="obj.a100" :disabled="obj.a100Flag" /></td>
        <td><el-input v-model="obj.a109" :disabled="obj.a109Flag" /></td>
      </tr>
      <tr>
        <td rowspan="2">部门管理</td>
        <td>上下刊、监测报告</td>
        <td>20%</td>
        <td>在上下刊48小时内提供上下刊报告到客眼(未达成扣2分)</td>
        <td>客服部</td>
        <td><el-input v-model="obj.a101" :disabled="obj.a101Flag" /></td>
        <td><el-input v-model="obj.a110" :disabled="obj.a110Flag" /></td>
      </tr>
      <tr>
        <td>配合工程部工作</td>
        <td>20%</td>
        <td>
          1、负责每月一次培训工程部人员拍照；2、负责协调喷绘按时（普通单当天下单第二天到仓库，加急单当天下单第二天上班后即到仓库）到达仓库。（未达成扣2分）
        </td>
        <td>工程部</td>
        <td><el-input v-model="obj.a102" :disabled="obj.a102Flag" /></td>
        <td><el-input v-model="obj.a111" :disabled="obj.a111Flag" /></td>
      </tr>
      <tr>
        <td>公司自宣</td>
        <td>公司自宣</td>
        <td>10%</td>
        <td>保证公司品牌自宣所需设计需求;及时完成公司指导的的设计比赛(未达成扣2分)</td>
        <td>总经理</td>
        <td><el-input v-model="obj.a103" :disabled="obj.a103Flag" /></td>
        <td><el-input v-model="obj.a112" :disabled="obj.a112Flag" /></td>
      </tr>
      <tr>
        <td>公司制度</td>
        <td>遵守公司规章</td>
        <td>10%</td>
        <td>
          对公司制度及企业文化的理解和执行，
          履行本部门工作中的行为表现
        </td>
        <td>督导</td>
        <td><el-input v-model="obj.a104" :disabled="obj.a104Flag" /></td>
        <td><el-input v-model="obj.a113" :disabled="obj.a113Flag" /></td>
      </tr>
      <tr>
        <td>加分项</td>
        <td>增量工作内容</td>
        <td>&nbsp;</td>
        <td>超出岗位职责范围、领导交办较为繁杂的事务、工作表现卓越等</td>
        <td>总经理</td>
        <td><el-input v-model="obj.a105" :disabled="obj.a105Flag" /></td>
        <td><el-input v-model="obj.a114" :disabled="obj.a114Flag" /></td>
      </tr>
      <tr>
        <td>&nbsp;</td>
        <td>对公司的建议</td>
        <td>&nbsp;</td>
        <td>对市场拓展、业务销售、内部管理等建设性意见</td>
        <td>总经理</td>
        <td><el-input v-model="obj.a106" :disabled="obj.a106Flag" /></td>
        <td><el-input v-model="obj.a115" :disabled="obj.a115Flag" /></td>
      </tr>
      <tr>
        <td colspan="5"></td>
        <td>自评:{{myScore}}</td>
        <td>综合考核率:{{otherScore}}</td>
      </tr>
    </table>
    <history :process="process"></history>
    <files></files>
  </section>
</template>
<script>
import mixin from '@/mixins/index.js'
import history from '../service/components/process'
import files from '../service/components/files'
import { sum } from '@/utils/domUtils.js'
// import { save, info, getAutoKey } from '@/api/oa/index.js'
const obj = {}
for (let i = 98; i <= 115; i++) {
  obj[`a${i}`] = ''
  obj[`a${i}Flag`] = true
}
export default {
  mixins: [mixin],
  data () {
    return {
      reason: '',
      truename: '',
      department: '',
      flag: false,
      value: '',
      obj: JSON.parse(JSON.stringify(obj)),
      applyTime: '',
      gangwei: '',
      file_paths: [],
      file_names: [],
      field_ids: [],
      field_vals: [],
      autoField: []
    }
  },
  components: { history, files },
  props: ['curDepartment', 'userInfo', 'approve', 'staff', 'addDofield', 'departments', 'process'],
  computed: {
    uploadArr () {
      return this.$store.state.uploadArr
    },
    myScore () {
      const result = []
      for (let i = 98; i <= 106; i++) {
        if (this.obj[`a${i}`]) {
          result.push(this.obj[`a${i}`])
        }
      }
      return sum(result)
    },
    otherScore () {
      const result = []
      for (let i = 107; i <= 115; i++) {
        if (this.obj[`a${i}`]) {
          result.push(this.obj[`a${i}`])
        }
      }
      return sum(result)
    }
  },
  watch: {
    addDofield () {
      this.addDofieldRender()
    }
  },
  mounted () {
    this.$nextTick(() => {
      this.obj = JSON.parse(JSON.stringify(obj))
      if (this.$route.query.from === 'new') {
        this.disabled = true
      } else {
        this.infoFunc()
      }
    })
  },
  methods: {
  }
}
</script>
